export default defineEventHandler(async (event) => {
  const id = getRouterParam(event, 'id');
  const body = await readBody(event);

  // 模拟更新分类
  const updatedCategory = {
    id: Number.parseInt(id),
    name: body.name,
    code: body.code,
    description: body.description || '',
    parent_id: body.parent_id || null,
    level: body.parent_id ? 2 : 1,
    serial_number: body.serial_number || 1,
    icon: body.icon || 'ant-design:folder-outlined',
    color: body.color || '#1890ff',
    display_config: body.display_config || {},
    category_type: body.category_type || 'RESOURCE',
    status: body.status || 1,
    tenant_id: 1,
    creator: 'admin',
    create_time: new Date().toISOString(),
    updater: 'admin',
    update_time: new Date().toISOString(),
    deleted: 0,
  };

  return {
    code: 0,
    data: updatedCategory,
    msg: '分类更新成功',
  };
});
